using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NTTHAO.Web.BL.CommonPage;
using NTTHAO.CommonWeb;

public partial class Sites_ThanhDuy_Webparts_Common_Videos : NTTHAO.CommonWeb.CommonUserControl
{
    public static readonly int PAGE_SIZE = 12;
    public CommonPageGroup _Group = null;
    public CommonMenu _Menu = null;
    public DataTable _List = null;

    public int _PageNo = 1;
    public int _PageCount = 1;
    public long _TotalItem = 0;
    public string _BaseURL = "/vi/";

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            _Group = this.GetCurrentPageGroup();
            _Menu = this.GetCurrentMenu();
            if (_Menu == null)
            {
                return;
            }
            _PageNo = this.GetCurrentPage();

            _BaseURL = Request.RawUrl;
            if (_BaseURL.IndexOf("/page/", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                _BaseURL = _BaseURL.Substring(0, _BaseURL.IndexOf("/page/", StringComparison.OrdinalIgnoreCase) + 1);
            }

            DataSet ds = CommonPageContent.GetPageByMenuID(_Menu.ID, 1, true, 0, ContentSortTypes.DefaultThenInsertTimeDecrease, _PageNo, PAGE_SIZE, ref _TotalItem);
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                _List = ds.Tables[0];
                this._PageCount = (int)(this._TotalItem / PAGE_SIZE + (this._TotalItem % PAGE_SIZE != 0 ? 1 : 0));
                this._PageCount = this._PageCount < 1 ? 1 : this._PageCount;
            }

            this.Session["PAGE_TITLE"] = _Menu.Text;
            this.Session["PAGE_DESCRIPTION"] = _Menu.Description;
        }
        catch { }
    }

    public string GetURL(string menuPath, int contentID, string contentURLText)
    {
        return "/" + _Group.URLName + "/" + CommonMenu.GetUrlPath(menuPath) + "/" + contentURLText + "_" + contentID.ToString() + ".html";
    }
}
